﻿using System.Configuration;

namespace Expect.Core.Config
{
    /// <summary>
    /// List of report tokens
    /// </summary>
    [ConfigurationCollection(typeof(ReportTokenElement), CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
    public class ReportTokens : ConfigurationElementCollection
    {
        /// <summary>
        /// Add an element to the list
        /// </summary>
        /// <param name="elt"></param>
        public void Add(ReportTokenElement elt)
        {
            this.BaseAdd(elt);
        }

        /// <summary>
        /// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </summary>
        /// <returns>
        /// A new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        protected override ConfigurationElement CreateNewElement()
        {            
            return new ReportTokenElement();
        }

        /// <summary>
        /// Gets the element key for a specified configuration element when overridden in a derived class.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        /// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for. 
        /// </param>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ReportTokenElement)element).Token;
        }
    }
}
